/**
 * @author Andrey Anisimov <hercules@inbox.ru>
 */

import core.effect.Tween;

class FadeOut extends Tween {

    /**
     * @param target {Object} Object implementing <code>setOpacity(o)</code> and <code>getOpacity</code> methods.
     * @param duration {int} Effect duration, in milliseconds.
     * @param interval {core.util.Timer} Effect timer.
     * @param easing {core.effect.easing.*} Easing effect.
     * @param easingType {String} (optional) Easing type (default is Tween.EASE_IN).
     * @constructor
     */
    this.FadeOut = function (target, duration, timer, easing, easingType) {
        super(duration, timer, 0, target.getOpacity(), easing, easingType);
        this.target = target;
    };

    /**
     * @inheritDoc
     */
    this.play = function(time) {
        this.setEndPosition(this.target.getOpacity());
        super.play(time);
    };

    /**
     * @protected
     * @see Tween.playback()
     */
    this.playback = function () {
        this.target.setOpacity(this.getEndPosition() - this.getPosition());
    }
}